VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.UserControl FSMSQuote 
   ClientHeight    =   525
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   555
   Picture         =   "FSMSQuote.ctx":0000
   ScaleHeight     =   525
   ScaleWidth      =   555
   ToolboxBitmap   =   "FSMSQuote.ctx":03FD
   Begin MSWinsockLib.Winsock Winsock1 
      Left            =   0
      Top             =   0
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
End
Attribute VB_Name = "FSMSQuote"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'***************************************************************
'Project: FXRSQuote
'
'Author: Chris Elwell
'
'Date: 9/19/2003
'
'Description: This is a UserControl that returns the lowest
'rate and service from any origin ZIP/ST to any destination
'ZIP/ST for a given Ship Date/Delivery Date combination.
'Programmers also have access to the individual details for
'each service (rates, commit dates, and errors), the Express
'Service Area, and Billed weights for Ground and Express.
'
'Events:
'FXRSConnected - fires when Winsock.state = 7 (sckConnected)
'FXRSClosed - fires when disconnected to FXRS
'QuoteComplete - fires after the Optimization has completed
'QuoteError - fires for various error conditions
'
'Methods:
'FXRSConnect - to connect to FXRS
'FXRSDisconnect - to disconnect form FXRS
'DoQuote - to perform the quote
'
'Properties: (see individual property details in declarations below)
'   Shipment properties - write only
'   Residential Charges Properties - write only
'   Special Services properties - write only
'   Rate properties - read only - rates returned from FXRS
'   Commit properties - read only - commit and time-in-transit delivery dates
'   Service error properties - read only - errors returned from FXRS
'   Optimized properties - read only - lowest rate and service, or error
'   Winsock State property - read only - check the winsock state
'   Service area property - read only - Express service area for the shipment
'   Billed weights property - read only - billed weights for Express & GR/FHD
'
'Example Usage:
'1. Add FXRSQuote.ctl to your project
'2. Dimension and instantiate a FXRSQuote.ctl object in your project.
'3. Call FXRSConnect Method to connect to FXRS.
'4. Create an ctlFXRS_FXRSConnected() event sub. Add code in this
'   sub that sets the shipment properties required to perform the
'   quote, then invoke the DoQuote method.
'5. Create a ctlFXRS_QuoteComplete() event sub. In this sub assign the
'   required properties to your variables. E.G.
'   strServiceToUse = .Optimized_Svc
'6. Create a ctlFXRS_QuoteError() event sub. In this sub use a
'   message box to display error messages. Note: Individual service
'   errors (PO_Error, SO_Error, etc.) do NOT raise this event.
'
'Updated: 6/14/2004
'         Removed Residential surcharge properties, which are now returned
'         in FXRS0720.
'         Replaced TransactionBuilder with updated version that doesn't
'         add fields if data is "".
'
'2007-05-15, JFW, Fix quote for weight type from Ship screen.
'
'***************************************************************

Option Explicit
Option Compare Text
Option Base 1
'********************************
'Events
'********************************
Event FXRSConnected()
Event FXRSClosed()
Event QuoteComplete()
Event QuoteError()
Event RatingError()

'********************************
'Local variables
'********************************
Dim m_str34(6) As String            'Gross Rate vars
Dim m_str36(6) As String            'Discount vars
Dim m_str35(6) As String            'Total surcharge vars
Dim m_str421(6) As String           'Declared Val surchg vars - Not included in F35
Dim m_str37(6) As String            'Net Rate vars
Dim m_str1596(6) As String          'Total handling chgs vars
Dim m_str1598(6) As String          'Total customer chg - Net + Handling
Dim m_str1519(6) As String          'List Gross Rate vars
Dim m_str1507(6) As String          'List Surcharge vars
Dim m_str1523(6) As String          'List Declared Val surchg - Not included in F1507
Dim m_str1528(6) As String          'List Net Rate vars
Dim m_str1597(6) As String          'List Handling vars
Dim m_str1599(6) As String          'Total List customer chg - List Net + List Handling
Dim m_str3(6) As String             'Error var for errors returned from FXRS
Dim m_CommitDate(6) As String       'Holds Service commit dates
Dim m_Optimized_Rate As String      'Optimized Rate
Dim m_Optimized_Svc As String       'Optimized SvcCode
Dim m_Error As String               'Error when no svcs are available
Dim m_RatingError As String         'If field 1125 is returned processing is stopped and RatingError event is raised
Dim m_State As String               'Winsock State
Dim m_DoOptimize As Boolean         'Flag for Optimizing
'**********************************
'FXRS input variables
Dim m_str8 As String                'Origin State
Dim m_str9 As String                'Origin ZIP
Dim m_str16 As String               'Dest State
Dim m_str17 As String               'Destination ZIP
Dim m_str50 As String               'Destination Country
Dim m_str116 As String              '# of pkgs
Dim m_str1670 As String               'Weight
Dim m_str75 As String               ' 2007-05-15, JFW, Missing this and assuming KG
Dim m_str24 As String               'Ship Date
Dim m_str26 As String               'Declared Value
Dim m_str27 As String               'COD flag
Dim m_str57 As String               'Height Dim
Dim m_str58 As String               'Width Dim
Dim m_str59 As String               'Length Dim
Dim m_str440 As String              'Residential Flag
Dim m_str498 As String              'Meter #
Dim m_str1090 As String             'Currency
Dim m_str1266 As String             'Saturday Del Flag
Dim m_str1588 As String             'Handling chg type - 1 - Fixed, 2 - % of Net - Surchgs, 3 - % of Net
Dim m_str1595_PO As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1595_SO As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1595_ES As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1595_XS As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1595_GR As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1595_HD As String          'Handling chg amt or % - 2 implied decimals
Dim m_str1606 As String             'Appl point - 0 or "", apply to pkg, 1 apply to shipment
Dim m_str3008 As String             'Ground FHD APOD
Dim m_str3009 As String             'Ground FHD AOD
Dim m_str3018 As String             'Ground FHD Non-standard pkg
Dim m_str3019 As String             'FHD Sig Svc
Dim m_str3020 As String             'FHD Special
'**********************************
Dim m_DelDate As String             'Date package it to be delivered
Dim m_Service(6) As String          'Service codes
Dim m_intSVC As Integer             'Counter for Service index
Dim m_str33 As String             'Service Area
Dim m_FXRS_IP As String             'FXRS IP Address
Dim m_FXRS_Port As Integer          'FXRS socket port
Dim m_str60_Express As String    'Billed Weight returned from FXRS for Express Svcs
Dim m_str60_Ground As String     'Billed Weight returned from FXRS for GR and HD Svcs
Dim m_strErrorLocation As String                'Used to identify module in error handling
Dim WithEvents m_clsFXRS As clsFXRSParser       'FXRS Parser class
Attribute m_clsFXRS.VB_VarHelpID = -1
'**********************************
' Shipment properties
'********************************
'REQUIRED - Shipper ZIP
Public Property Let f9(str9 As String)
    m_str9 = str9
End Property
'REQUIRED - Shipper 2-char State
Public Property Let f8(str8 As String)
    m_str8 = str8
End Property
'REQUIRED - Destination ZIP
Public Property Let f17(str17 As String)
    m_str17 = str17
End Property
'REQUIRED - Destination 2-char State
Public Property Let f16(str16 As String)
    m_str16 = str16
End Property
'REQUIRED - Destination Country
Public Property Let f50(str50 As String)
    m_str50 = str50
End Property
'REQUIRED - # of Pkgs
Public Property Let f116(str116 As String)
    m_str116 = str116
End Property
'REQUIRED - Package weight
Public Property Let f1670(str1670 As String)
    m_str1670 = str1670
End Property
' 2007-05-15, JFW
'REQUIRED - Package weight type
Public Property Let f75(str75 As String)
    m_str75 = str75
End Property
'REQUIRED - Date customer needs package delivered by
Public Property Let DelDate(strDelDate As String)
    m_DelDate = strDelDate
End Property
'OPTIONAL - Ship Date - Defaults to today
Public Property Let f24(str24 As String)
    m_str24 = str24
End Property
'OPTIONAL - Length Dimension
Public Property Let f59(str59 As String)
    m_str59 = str59
End Property
'OPTIONAL - Width Dimension
Public Property Let f58(str58 As String)
    m_str58 = str58
End Property
'OPTIONAL - Height Dimension
Public Property Let f57(str57 As String)
    m_str57 = str57
End Property
'OPTIONAL - Declared value - whole dollar amount, no decimal places.
Public Property Let f26(str26 As String)
    m_str26 = str26
End Property
'OPTIONAL - Meter# - defaults to Master Meter # if not included, however it
'is good practice to always include this.
Public Property Let f498(str498 As String)
    m_str498 = str498
End Property
'OPTIONAL - Currency - for international
Public Property Let f1090(str1090 As String)
    m_str1090 = str1090
End Property
'**********************************
'Special Services Properties
'********************************
'OPTIONAL - COD flag "Y" or "N"
Public Property Let f27(str27 As String)
    m_str27 = IIf(Trim(str27) = "Y", "Y", "")
End Property
'OPTIONAL - Residential flag "Y" or "" - will add Residential charges above
'only if this flag is set to "Y"
Public Property Let f440(str440 As String)
    m_str440 = IIf(Trim(str440) = "Y", "Y", "")
End Property
'OPTIONAL - Saturday Delivery flag "Y" or ""
Public Property Let f1266(str1266 As String)
    m_str1266 = IIf(Trim(str1266) = "Y", "Y", "")
End Property
'OPTIONAL - Handling Chg Type - "1", "2", or "3"
Public Property Let f1588(str1588 As String)
    m_str1588 = str1588
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_PO(str1595 As String)
    m_str1595_PO = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_SO(str1595 As String)
    m_str1595_SO = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_ES(str1595 As String)
    m_str1595_ES = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_XS(str1595 As String)
    m_str1595_XS = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_GR(str1595 As String)
    m_str1595_GR = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Amount - 2 implied decimals
Public Property Let F1595_HD(str1595 As String)
    m_str1595_HD = Format(Val(str1595) * 100, "#####")
End Property
'OPTIONAL - Handling Chg Appl Point - 1 (Default) Pkg level, 2 - Shipment level
Public Property Let f1606(str1606 As String)
    m_str1606 = str1606
End Property
'OPTIONAL - Ground/FHD APOD
Public Property Let f3008(str3008 As String)
    m_str3008 = str3008
End Property
'OPTIONAL - Ground/FHD AOD
Public Property Let f3009(str3009 As String)
    m_str3009 = str3009
End Property
'OPTIONAL - Ground/FHD Non-standard pkg
Public Property Let f3018(str3018 As String)
    m_str3018 = str3018
End Property
'OPTIONAL - FHD Sig Svc
Public Property Let f3019(str3019 As String)
    m_str3019 = str3019
End Property
'OPTIONAL - FHD Special Svc
Public Property Let f3020(str3020 As String)
    m_str3020 = str3020
End Property
'********************************
'Gross Rate properties -  returned gross rates (field 34) for individual services
'********************************
Public Property Get F34_PO() As String
    F34_PO = m_str34(1)
End Property
Public Property Get F34_SO() As String
    F34_SO = m_str34(2)
End Property
Public Property Get F34_ES() As String
    F34_ES = m_str34(3)
End Property
Public Property Get F34_XS() As String
    F34_XS = m_str34(4)
End Property
Public Property Get F34_GR() As String
    F34_GR = m_str34(5)
End Property
Public Property Get F34_HD() As String
    F34_HD = m_str34(6)
End Property
'********************************
'Discount properties -  returned discounts (field 36) for individual services
'********************************
Public Property Get F36_PO() As String
    F36_PO = m_str36(1)
End Property
Public Property Get F36_SO() As String
    F36_SO = m_str36(2)
End Property
Public Property Get F36_ES() As String
    F36_ES = m_str36(3)
End Property
Public Property Get F36_XS() As String
    F36_XS = m_str36(4)
End Property
Public Property Get F36_GR() As String
    F36_GR = m_str36(5)
End Property
Public Property Get F36_HD() As String
    F36_HD = m_str36(6)
End Property
'********************************
'Surcharge properties -  returned total surcharges (field 35) for individual services
'********************************
Public Property Get F35_PO() As String
    F35_PO = m_str35(1)
End Property
Public Property Get F35_SO() As String
    F35_SO = m_str35(2)
End Property
Public Property Get F35_ES() As String
    F35_ES = m_str35(3)
End Property
Public Property Get F35_XS() As String
    F35_XS = m_str35(4)
End Property
Public Property Get F35_GR() As String
    F35_GR = m_str35(5)
End Property
Public Property Get F35_HD() As String
    F35_HD = m_str35(6)
End Property
'********************************
'DV Surcharge properties -  returned DV Surchg (field 421) Not included in Total surchg
'********************************
Public Property Get F421_PO() As String
    F421_PO = m_str421(1)
End Property
Public Property Get F421_SO() As String
    F421_SO = m_str421(2)
End Property
Public Property Get F421_ES() As String
    F421_ES = m_str421(3)
End Property
Public Property Get F421_XS() As String
    F421_XS = m_str421(4)
End Property
Public Property Get F421_GR() As String
    F421_GR = m_str421(5)
End Property
Public Property Get F421_HD() As String
    F421_HD = m_str421(6)
End Property
'********************************
'Net Rate properties -  returned rates for individual services
'********************************
Public Property Get F37_PO() As String
    F37_PO = m_str37(1)
End Property
Public Property Get F37_SO() As String
    F37_SO = m_str37(2)
End Property
Public Property Get F37_ES() As String
    F37_ES = m_str37(3)
End Property
Public Property Get F37_XS() As String
    F37_XS = m_str37(4)
End Property
Public Property Get F37_GR() As String
    F37_GR = m_str37(5)
End Property
Public Property Get F37_HD() As String
    F37_HD = m_str37(6)
End Property
'********************************
'Handling chgs properties -  returned Handling charges (field 1596) for individual services
'********************************
Public Property Get F1596_PO() As String
    F1596_PO = m_str1596(1)
End Property
Public Property Get F1596_SO() As String
    F1596_SO = m_str1596(2)
End Property
Public Property Get F1596_ES() As String
    F1596_ES = m_str1596(3)
End Property
Public Property Get F1596_XS() As String
    F1596_XS = m_str1596(4)
End Property
Public Property Get F1596_GR() As String
    F1596_GR = m_str1596(5)
End Property
Public Property Get F1596_HD() As String
    F1596_HD = m_str1596(6)
End Property
'********************************
'Tot Customer chg properties -  returned Total customer chg (field 1598) for individual services
'********************************
Public Property Get F1598_PO() As String
    F1598_PO = m_str1598(1)
End Property
Public Property Get F1598_SO() As String
    F1598_SO = m_str1598(2)
End Property
Public Property Get F1598_ES() As String
    F1598_ES = m_str1598(3)
End Property
Public Property Get F1598_XS() As String
    F1598_XS = m_str1598(4)
End Property
Public Property Get F1598_GR() As String
    F1598_GR = m_str1598(5)
End Property
Public Property Get F1598_HD() As String
    F1598_HD = m_str1598(6)
End Property
'********************************
'List Gross properties -  returned List Gross rates (field 1519) for individual services
'********************************
Public Property Get F1519_PO() As String
    F1519_PO = m_str1519(1)
End Property
Public Property Get F1519_SO() As String
    F1519_SO = m_str1519(2)
End Property
Public Property Get F1519_ES() As String
    F1519_ES = m_str1519(3)
End Property
Public Property Get F1519_XS() As String
    F1519_XS = m_str1519(4)
End Property
Public Property Get F1519_GR() As String
    F1519_GR = m_str1519(5)
End Property
Public Property Get F1519_HD() As String
    F1519_HD = m_str1519(6)
End Property
'********************************
'List Surcharge properties -  returned List Surcharges (field 1507) for individual services
'********************************
Public Property Get F1507_PO() As String
    F1507_PO = m_str1507(1)
End Property
Public Property Get F1507_SO() As String
    F1507_SO = m_str1507(2)
End Property
Public Property Get F1507_ES() As String
    F1507_ES = m_str1507(3)
End Property
Public Property Get F1507_XS() As String
    F1507_XS = m_str1507(4)
End Property
Public Property Get F1507_GR() As String
    F1507_GR = m_str1507(5)
End Property
Public Property Get F1507_HD() As String
    F1507_HD = m_str1507(6)
End Property
'********************************
'List DV Surcharge properties -  returned DV Surchg (field 1523) Not included in Total surchg
'********************************
Public Property Get F1523_PO() As String
    F1523_PO = m_str1523(1)
End Property
Public Property Get F1523_SO() As String
    F1523_SO = m_str1523(2)
End Property
Public Property Get F1523_ES() As String
    F1523_ES = m_str1523(3)
End Property
Public Property Get F1523_XS() As String
    F1523_XS = m_str1523(4)
End Property
Public Property Get F1523_GR() As String
    F1523_GR = m_str1523(5)
End Property
Public Property Get F1523_HD() As String
    F1523_HD = m_str1523(6)
End Property
'********************************
'List Net Rate properties -  returned List Net Rates (field 1528) for individual services
'********************************
Public Property Get F1528_PO() As String
    F1528_PO = m_str1528(1)
End Property
Public Property Get F1528_SO() As String
    F1528_SO = m_str1528(2)
End Property
Public Property Get F1528_ES() As String
    F1528_ES = m_str1528(3)
End Property
Public Property Get F1528_XS() As String
    F1528_XS = m_str1528(4)
End Property
Public Property Get F1528_GR() As String
    F1528_GR = m_str1528(5)
End Property
Public Property Get F1528_HD() As String
    F1528_HD = m_str1528(6)
End Property
'********************************
'List Handling chg properties -  returned List Handling chgs (field 1597) for individual services
'********************************
Public Property Get F1597_PO() As String
    F1597_PO = m_str1597(1)
End Property
Public Property Get F1597_SO() As String
    F1597_SO = m_str1597(2)
End Property
Public Property Get F1597_ES() As String
    F1597_ES = m_str1597(3)
End Property
Public Property Get F1597_XS() As String
    F1597_XS = m_str1597(4)
End Property
Public Property Get F1597_GR() As String
    F1597_GR = m_str1597(5)
End Property
Public Property Get F1597_HD() As String
    F1597_HD = m_str1597(6)
End Property
'********************************
'List Tot Customer chg properties -  returned List Total customer chgs (field 1599) for individual services
'********************************
Public Property Get F1599_PO() As String
    F1599_PO = m_str1599(1)
End Property
Public Property Get F1599_SO() As String
    F1599_SO = m_str1599(2)
End Property
Public Property Get F1599_ES() As String
    F1599_ES = m_str1599(3)
End Property
Public Property Get F1599_XS() As String
    F1599_XS = m_str1599(4)
End Property
Public Property Get F1599_GR() As String
    F1599_GR = m_str1599(5)
End Property
Public Property Get F1599_HD() As String
    F1599_HD = m_str1599(6)
End Property
'********************************
'Commit properties - actual date service will del by
'Note: is there's an error these are set to 01/01/1900
'********************************
Public Property Get PO_Commit() As String
    PO_Commit = m_CommitDate(1)
End Property
Public Property Get SO_Commit() As String
    SO_Commit = m_CommitDate(2)
End Property
Public Property Get ES_Commit() As String
    ES_Commit = m_CommitDate(3)
End Property
Public Property Get XS_Commit() As String
    XS_Commit = m_CommitDate(4)
End Property
Public Property Get GR_Commit() As String
    GR_Commit = m_CommitDate(5)
End Property
Public Property Get HD_Commit() As String
    HD_Commit = m_CommitDate(6)
End Property
'********************************
'Error properties - FXRS errors and internally generated errors
'for some Ground and FHD errors not caught by FXRS
'********************************
Public Property Get F3_PO() As String
    F3_PO = m_str3(1)
End Property
Public Property Get F3_SO() As String
    F3_SO = m_str3(2)
End Property
Public Property Get F3_ES() As String
    F3_ES = m_str3(3)
End Property
Public Property Get F3_XS() As String
    F3_XS = m_str3(4)
End Property
Public Property Get F3_GR() As String
    F3_GR = m_str3(5)
End Property
Public Property Get F3_HD() As String
    F3_HD = m_str3(6)
End Property
'********************************
'Optimized properties
'********************************
'Optimization flag. If true optimize.
Public Property Let DoOptimize(blnOptimize As Boolean)
    m_DoOptimize = blnOptimize
End Property
Public Property Get DoOptimize() As Boolean
    DoOptimize = m_DoOptimize
End Property
Public Property Get Optimized_Rate() As String
    Optimized_Rate = m_Optimized_Rate
End Property
Public Property Get Optimized_Svc() As String
    Optimized_Svc = m_Optimized_Svc
End Property
'********************************
'Error properties
'********************************
'This includes and program generated errors
Public Property Get Quote_Error() As String
    Quote_Error = m_Error
End Property
'This property should be read in a RatingError event sub. If field 1125 has an error code
'a lookup on the code should be performed.
Public Property Get Rating_Error() As String
    Rating_Error = m_RatingError
End Property
'*********************************
'Winsock properties
'********************************
Public Property Get State() As String
    State = m_State
End Property
'**********************************
'Service Area
'**********************************
Public Property Get F33() As String
    F33 = m_str33
End Property
'**********************************
'Billed weight Express & Ground/HD
'**********************************
'Billed weights can be different for Express and Ground when dimensions are passed
Public Property Get F60_Express() As String
    F60_Express = m_str60_Express
End Property
Public Property Get F60_Ground() As String
    F60_Ground = m_str60_Ground
End Property
'**********************************
'Public Functions
'**********************************
'FXRSConnect - use to connect to FXRS. IP address is required, socket port is
'optional and is set to 2000 if not passed.
Public Sub FXRSConnect(strIP As String, Optional strPort As String = "2000")
    
    On Error GoTo EH
    
    If Winsock1.State <> 7 Then
        Winsock1.Connect strIP, strPort
    End If
    
    Exit Sub
EH:
    m_Error = Err.Description & " in FXRSConnect"
    RaiseEvent QuoteError
    m_State = Winsock1.State

End Sub
'FXRSDisconnect - use to disconnect from FXRS
Public Sub FXRSDisconnect()
    
    On Error Resume Next
    If Winsock1.State <> 0 Then
        Winsock1.Close
        RaiseEvent FXRSClosed
        m_State = Winsock1.State
    End If
    
End Sub
'DoQuote - use to begin quoting and optimization. Do not pass an index
'when calling from your program. The index is defaulted to 1 to begin
'the quote process.
Public Sub DoQuote()
        
    On Error GoTo EH
    
    'Do a couple date checks if optimizing
    If m_DoOptimize Then
        If m_DelDate = "" Or m_str24 = "" Then
            m_Error = "Both Ship Date and Delivery Date are required fields"
            RaiseEvent QuoteError
            Exit Sub
        End If
        If DateDiff("d", m_DelDate, m_str24) > 0 Then
            m_Error = "The Delivery Date is less than the Ship Date"
            RaiseEvent QuoteError
            Exit Sub
        End If
        If DateDiff("d", Date, m_str24) < 0 Then
            m_Error = "The Ship Date is less than Today's Date"
            RaiseEvent QuoteError
            Exit Sub
        End If
        'Check delivery days
        If m_str1266 = "Y" And Weekday(m_DelDate) <> 7 Then
            m_Error = "The Delivery Date is not a Saturday"
            RaiseEvent QuoteError
            Exit Sub
        ElseIf Weekday(m_DelDate) = 1 Then
            m_Error = "Sunday is not a valid delivery day"
            RaiseEvent QuoteError
            Exit Sub
        End If
    End If
    
    Call NextQuote(m_intSVC)
    
    Exit Sub
EH:
    m_Error = Err.Description & " in DoQuote"
    RaiseEvent QuoteError

End Sub
'**********************************
'Private Functions
'**********************************
Private Sub NextQuote(intIndex As Integer)
    
    On Error GoTo EH
    
    'Reset variables
    If intIndex = 1 Then
        Call UserControl_Initialize
    End If
    
    'Check is winsock is connected and send data
    If Winsock1.State = 7 Then
        
        Debug.Print "FSMSQuote SendData", BuildTrans(m_Service(intIndex))
        
        Winsock1.SendData BuildTrans(m_Service(intIndex))
    Else
        If Winsock1.State <> 0 Then
            Winsock1.Close
        End If
        RaiseEvent FXRSClosed
    End If
    
    Exit Sub
EH:
    m_Error = Err.Description & " in NextQuote"
    RaiseEvent QuoteError

End Sub
'BuildTrans - builds the FXRS transaction strings
Private Function BuildTrans(ByVal str1274 As String)
    'Called from: DoQuote
    'Purpose: Creates FXRS input string
    
    Dim str24 As String     'Converted ShipDate
    Dim str26 As String     'Converted Declared Value
    Dim strData As String   'Transaction string
    Dim i As Integer
    
    On Error GoTo EH
    
    'Convert Ship Date to a sting in FXRS format (mmmmddyy)
    str24 = Format(m_str24, "YYYYMMDD")
    'Convert from decimal to 2 implied decimal places
    str26 = Format(Val(m_str26), "#####")
    
    strData = ""
    TransactionBuilder strData, 0, "020"                    'Origin Zip
    TransactionBuilder strData, 1, "Rate/Route"             'TransID
    TransactionBuilder strData, 8, m_str8                   'Origin Zip
    TransactionBuilder strData, 9, m_str9                   'Origin State
    TransactionBuilder strData, 16, m_str16                 'Destination Zip
    TransactionBuilder strData, 17, m_str17                 'Destination State
    TransactionBuilder strData, 1670, RemoveSpecial(ImpliedDecimal(m_str1670))  'Weight (first occurrence)
    ' 2007-05-15, JFW
    TransactionBuilder strData, 75, m_str75
    'If # of pkgs > 1 add multi-occurrence weight fields
    If Val(m_str116) > 1 Then
        For i = 2 To Val(m_str116)
            TransactionBuilder strData, "1670-" & Trim(Str(i)), RemoveSpecial(ImpliedDecimal(m_str1670))   'Weight (multiple occurrence)
        Next
    End If
    TransactionBuilder strData, 23, "1"                     'Payment
    TransactionBuilder strData, 24, str24                   'ShipDate
    TransactionBuilder strData, 26, str26                   'Declared Value
    TransactionBuilder strData, 27, m_str27                 'COD Flag
    TransactionBuilder strData, 50, m_str50                    'Destination Country
    TransactionBuilder strData, 53, "100"                   'COD Amount
    TransactionBuilder strData, 57, m_str57                 'Dim H
    TransactionBuilder strData, 58, m_str58                 'Dim W
    TransactionBuilder strData, 59, m_str59                 'Dim L
    TransactionBuilder strData, 440, m_str440               'Res Flag
    TransactionBuilder strData, 498, m_str498               'Meter Number

    '2006-10-04, JFW, TD rate quote with FXRS 0800
    If frmShip.f1482.Value = 1 Then
        TransactionBuilder strData, 541, "NYYYNNNNN"                               'Open Ship Flags
        TransactionBuilder strData, 542, g_strTDOpenShip
    End If
    
    TransactionBuilder strData, 1090, m_str1090
    TransactionBuilder strData, 1234, "3"                   'Rate/Route Flag
    TransactionBuilder strData, 1266, m_str1266             'Saturday Del
    TransactionBuilder strData, 1273, "01"                  'Packaging
    TransactionBuilder strData, 1958, "BOX"                                            'Intl Packaging Type
    TransactionBuilder strData, 1274, str1274               'Service
    'Ground and FHD special svcs
    If str1274 = "92" Or str1274 = "90" Then
        TransactionBuilder strData, 3008, m_str3008             'APOD
        TransactionBuilder strData, 3009, m_str3009             'AOD
        TransactionBuilder strData, 3018, m_str3018             'Non-Standard pkg
    End If
    If str1274 = "90" Then
        TransactionBuilder strData, 3019, m_str3019             'FHD Sig Svc
        TransactionBuilder strData, 3020, m_str3020             'FHD Special Svcs
    End If
    
    TransactionBuilder strData, 1588, m_str1588             'Handling Chg Type
    'Allows for different handling chgs by service
    Select Case m_intSVC
        Case 1
            TransactionBuilder strData, 1595, m_str1595_PO             'Handling Chg Amount
        Case 2
            TransactionBuilder strData, 1595, m_str1595_SO             'Handling Chg Amount
        Case 3
            TransactionBuilder strData, 1595, m_str1595_ES             'Handling Chg Amount
        Case 4
            TransactionBuilder strData, 1595, m_str1595_XS             'Handling Chg Amount
        Case 5
            TransactionBuilder strData, 1595, m_str1595_GR             'Handling Chg Amount
        Case 6
            TransactionBuilder strData, 1595, m_str1595_HD             'Handling Chg Amount
    End Select
    TransactionBuilder strData, 1606, m_str1606             'Handling Chg Appl Point
    TransactionBuilder strData, 3062, "2"                   'Rate Quote Type - 2 = both Discount and List
    TransactionBuilder strData, 99, ""
    
    BuildTrans = strData
    
    Exit Function
EH:
    m_Error = Err.Description & " in BuildTrans"
    RaiseEvent QuoteError

End Function
'---------------------------------------------------------------------------------------
' Module    : TransactionBuilder
' DateTime  : 8/03/2003
' Author    : Tim Johnson
' Modified  : Chris Elwell
' Mod Date  : 2/18/2004 - Field not added to transaction string if strFieldValue = ""
'             Also had to change FieldNumber data type from Int to String to allow for
'             multiple occurrence fields.
'             4/6/2004 - added line to remove double quotes from data.
' Purpose   : Function To Build Transactions - pass in a string variable, field number,
'             and data. The field and data are formatted and then the original
'             ByRef strTransactionString is modified.
'---------------------------------------------------------------------------------------
'
Public Function TransactionBuilder(ByRef strTransactionString As String, ByVal strFieldNumber As String, ByVal strFieldValue As String)
    
    On Error GoTo EH
    
    If (strFieldNumber = "99" Or strFieldValue <> "") Then
        'Remove double qoutes from data
        strFieldValue = Replace(strFieldValue, Chr(34), "")
        strTransactionString = strTransactionString & strFieldNumber & "," & Chr(34) & strFieldValue & Chr(34)
    End If
    
    Exit Function
EH:
    m_Error = Err.Description & " in TransactionBuilder"
    RaiseEvent QuoteError

End Function

Private Sub UserControl_Terminate()
    Set m_clsFXRS = Nothing
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Winsock1_Connect
' DateTime  : 12/08/2003
' Purpose   : Winsock connect event. Raise FXRSConnected Event
'---------------------------------------------------------------------------------------
'
Private Sub Winsock1_Connect()
    
    RaiseEvent FXRSConnected
    
End Sub

'Winsock1_DataArrival - Winsock DataArrival event procedure
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
   
    Dim strData As String
    
    On Error Resume Next
    
    'Retrieve FXRS reply from winsock buffer
    Winsock1.GetData strData
    
    Debug.Print "FSMSQuote DataArrival", strData
    
    'Pass reply to parse control
    m_clsFXRS.ParseData strData

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Winsock1_Error
' DateTime  : 12/08/2003
' Purpose   : Winsock error event. Close connect and raise QuoteError event.
'---------------------------------------------------------------------------------------
'
Private Sub Winsock1_Error(ByVal number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    
    On Error Resume Next
    
    m_Error = "FXRS Connection Error: " & Description
    If Winsock1.State <> 0 Then
        Winsock1.Close
    End If
    RaiseEvent QuoteError
    RaiseEvent FXRSClosed

End Sub
'm_clsFXRS_ParseComplete - this is the clsFXRSParser class
'ParseComplete event sub, which fires when a transaction has
'completed parsing.
Private Sub m_clsFXRS_ParseComplete()
    Dim i As Integer
    Dim strDelBy As String              'Express deliver by date
    Dim strDay As String                'Holds Day part of DelBy Date
    Dim strMonth As String              'Holds Month part of DelBy Date
    Dim intMonth As Integer             'Holds Month part of DelBy Date as INT
    Dim strYear As String               'Holds Year part of DelBy Date
    
    On Error GoTo EH
    
    With m_clsFXRS
        For i = 0 To .TotalFields - 1
            Select Case .Field(i)
                'FXRS Error text field
                Case "3"
                    m_str3(m_intSVC) = .Data(i)
                    Exit For
                'FXRS Rating Error
                Case "1125" '0 returned when there is no error
                    If .Data(i) <> "0" Then
                        m_str3(m_intSVC) = GetRateError(.Data(i))
                        Exit For
                    End If
                'Returned for Ground FHD when 1125 <> "0"
                Case "560"
                    m_str3(m_intSVC) = .Data(i)
                    Exit For
                'Gross rate
                Case "34"
                    m_str34(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Total discount
                Case "36"
                    m_str36(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Total Surcharges
                Case "35"
                    m_str35(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Net Rate
                Case "37"
                    m_str37(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Total discount
                Case "421"
                    m_str421(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Handling charge
                Case "1596"
                    m_str1596(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Total customer charge
                Case "1598"
                    m_str1598(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Gross rate
                Case "1519"
                    m_str1519(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Total Surcharges
                Case "1507"
                    m_str1507(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List DV Surcharges
                Case "1523"
                    m_str1523(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Net Rate
                Case "1528"
                    m_str1528(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Handling charge
                Case "1597"
                    m_str1597(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'List Total customer charge
                Case "1599"
                    m_str1599(m_intSVC) = Format(Val(.Data(i) * 0.01), "#####.00")
                'Express DeliverBy Date - convert to standard date format
                Case "409"
                    If .Data(i) = "" Then
                        m_str3(m_intSVC) = "This ZIP not served"
                    Else
                        strDelBy = .Data(i)
                        strDay = Left(strDelBy, 2)
                        strYear = "20" & Right(strDelBy, 2)
                        strMonth = Mid(strDelBy, 3, 3)
                        Select Case strMonth
                            Case "Jan"
                                intMonth = 1
                            Case "Feb"
                                intMonth = 2
                            Case "Mar"
                                intMonth = 3
                            Case "Apr"
                                intMonth = 4
                            Case "May"
                                intMonth = 5
                            Case "Jun"
                                intMonth = 6
                            Case "Jul"
                                intMonth = 7
                            Case "Aug"
                                intMonth = 8
                            Case "Sep"
                                intMonth = 9
                            Case "Oct"
                                intMonth = 10
                            Case "Nov"
                                intMonth = 11
                            Case "Dec"
                                intMonth = 12
                        End Select
                        'Save converted DeliverBy Date
                        m_CommitDate(m_intSVC) = DateSerial(Val(strYear), intMonth, Val(strDay))
                    End If
                'Express Service Area
                Case "33"
                    m_str33 = .Data(i)
                'Billed weight
                Case "60"
                    If m_intSVC < 5 Then
                        m_str60_Express = .Data(i)
                    ElseIf m_intSVC >= 5 And .Data(i) <> "0" Then
                        m_str60_Ground = .Data(i)
                    End If
                'Ground/FHD Time in Transit - add to Ship Date
                Case "3058"
                    If m_intSVC = 5 Then
                        'If Sat Del set error
                        If m_str1266 = "Y" Then
                            m_str3(m_intSVC) = "FedEx Ground does not deliver on Saturdays"
                        'Else Calculate Ground Delivery Date
                        Else
                            m_CommitDate(m_intSVC) = GroundDelDate(CDate(m_str24), CInt(.Data(i)))
                        End If
                    ElseIf m_intSVC = 6 Then
                        'If COD = Y set error, FHD does not support COD
                        If m_str27 = "Y" Then
                            m_str3(m_intSVC) = "FedEx Home Delivery does not support COD shipments"
                        'Else calculate FHD delivery date
                        Else
                            m_CommitDate(m_intSVC) = FHDDelDate(CDate(m_str24), CInt(.Data(i)))
                            'If Sat Del is selected and commit day is not Saturday, set error
                            If m_str1266 = "Y" And Weekday(m_CommitDate(m_intSVC)) <> 7 Then
                                m_str3(m_intSVC) = "Delivery day is not Saturday"
                            End If
                        End If
                    End If
            End Select
        Next
    End With
    
    'If there's an error for the service, set rate to 0 and commit date to 1/1/1900
    If m_str3(m_intSVC) <> "" Then
        m_CommitDate(m_intSVC) = "1/1/1900"
        m_str37(m_intSVC) = 0
    End If
    
    'If m_intSVC = 6 all services have been quoted so call optimize else
    'quote the next service
    If m_intSVC = 6 Then
        m_intSVC = 1
        'If optimizing call sub else raise QuoteComplete event
        If m_DoOptimize Then
            Call Optimize
        Else
            RaiseEvent QuoteComplete
        End If
    Else
        m_intSVC = m_intSVC + 1
        Call NextQuote(m_intSVC)
    End If
    
    Exit Sub
EH:
    m_Error = Err.Description & " in ParseComplete"
    RaiseEvent QuoteError

End Sub
'Optimize - this is called internally from m_clsFXRS_ParseComplete
'when all services have been quoted
Private Sub Optimize()
    
    Dim i, n
    Dim intMeetCommit(6) As Integer
    Dim strLowestSvc As String
    Dim strLowestRate As String
    
    On Error GoTo EH
    
    'Store the indexes for the services that meet commit date and have no error
    n = 0
    For i = 1 To 6
        If DateDiff("d", m_CommitDate(i), m_DelDate) >= 0 And m_str3(i) = "" Then
            n = n + 1
            intMeetCommit(n) = i
        End If
    Next
    'Set Lowest rate to high value initially
    strLowestRate = "99999.00"
    'If 1 or more loop through the values and select the lowest each time.
    If n >= 1 Then
        For i = 1 To n
            If Val(m_str37(intMeetCommit(i))) < Val(strLowestRate) Then
                strLowestRate = m_str37(intMeetCommit(i))
                strLowestSvc = m_Service(intMeetCommit(i))
            End If
        Next
        m_Optimized_Rate = strLowestRate
        m_Optimized_Svc = strLowestSvc
    'Else none meet commit, set error message and raise error event
    Else
        m_Error = "No services supported"
        RaiseEvent QuoteError
    End If
    
    RaiseEvent QuoteComplete
    
    Exit Sub
EH:
    m_Error = Err.Description & " in Optimize"
    RaiseEvent QuoteError

End Sub
'Initialize module variables.
Private Sub UserControl_Initialize()
    Dim i
    
    On Error GoTo EH
    
    Set m_clsFXRS = New clsFXRSParser
    'Set service codes
    m_Service(1) = "01" 'PO
    m_Service(2) = "05" 'SO
    m_Service(3) = "03" 'ES
    m_Service(4) = "20" 'XS
    m_Service(5) = "92" 'GR
    m_Service(6) = "90" 'HD

    For i = 1 To 6
        m_CommitDate(i) = "1/1/1900"
        m_str3(i) = ""
        m_str34(i) = ""
        m_str36(i) = ""
        m_str35(i) = ""
        m_str421(i) = ""
        m_str37(i) = ""
        m_str1596(i) = ""
        m_str1598(i) = ""
        m_str1519(i) = ""
        m_str1507(i) = ""
        m_str1528(i) = ""
        m_str1597(i) = ""
        m_str1599(i) = ""
    Next
    
    m_intSVC = 1
    If IsEmpty(m_str24) Then
        m_str24 = Date
    End If
    m_Optimized_Rate = ""
    m_Optimized_Svc = ""

    Exit Sub
EH:
    m_Error = Err.Description & " in UserControl_Initialize"
    RaiseEvent QuoteError

End Sub
'm_clsFXRS_ParseError - this is the clsFXRSParser class
'ParseError event sub. This takes the parse error from
'the class and assigns it to the local m_Error
'variable and raises the QuoteError event.
Private Sub m_clsFXRS_ParseError()
    m_Error = m_clsFXRS.Parse_Error
    RaiseEvent QuoteError
End Sub
'---------------------------------------------------------------------------------------
' Procedure : GroundDelDate
' DateTime  : 8/11/2004
' Purpose   : Takes a ShipDate and Transit Days and checks an array of known weekday
'             holidays through 2010 and adds a day to the Transit Days if any of the
'             holidays is between the ShipDate and the ShipDate + Transit Days.
'             Then adds the Transit Days to the weekday value of the ShipDate and if
'             greater than 6 adds 2 days to account for Sat and Sun.
'---------------------------------------------------------------------------------------
'
Private Function GroundDelDate(ByVal dteShipDate As Date, ByVal intTransitDays) As String

    Dim dteWeekDayHoliday(35) As Date       'Array for weekday holidays
    Dim i                                   'For loop counter
    Dim dteDelDate As Date                  'Delivery date - shipdate + transit days
    
    On Error GoTo EH
    
    'weekday holidays
    dteWeekDayHoliday(1) = #11/25/2004#
    dteWeekDayHoliday(2) = #11/24/2005#
    dteWeekDayHoliday(3) = #11/23/2006#
    dteWeekDayHoliday(4) = #11/29/2007#
    dteWeekDayHoliday(5) = #11/27/2008#
    dteWeekDayHoliday(6) = #11/26/2009#
    dteWeekDayHoliday(7) = #11/25/2010#
    dteWeekDayHoliday(8) = #5/31/2004#
    dteWeekDayHoliday(9) = #5/30/2005#
    dteWeekDayHoliday(10) = #5/29/2006#
    dteWeekDayHoliday(11) = #5/28/2007#
    dteWeekDayHoliday(12) = #5/26/2008#
    dteWeekDayHoliday(13) = #5/25/2009#
    dteWeekDayHoliday(14) = #5/31/2010#
    dteWeekDayHoliday(15) = #1/1/2007#
    dteWeekDayHoliday(16) = #1/1/2008#
    dteWeekDayHoliday(17) = #1/1/2009#
    dteWeekDayHoliday(18) = #1/1/2010#
    dteWeekDayHoliday(19) = #7/4/2005#
    dteWeekDayHoliday(20) = #7/4/2006#
    dteWeekDayHoliday(21) = #7/4/2007#
    dteWeekDayHoliday(22) = #7/4/2008#
    dteWeekDayHoliday(23) = #7/6/2009#
    dteWeekDayHoliday(24) = #7/5/2010#
    dteWeekDayHoliday(25) = #12/25/2006#
    dteWeekDayHoliday(26) = #12/25/2007#
    dteWeekDayHoliday(27) = #12/25/2008#
    dteWeekDayHoliday(28) = #12/25/2009#
    dteWeekDayHoliday(29) = #9/6/2004#      'Labor Day
    dteWeekDayHoliday(30) = #9/5/2005#
    dteWeekDayHoliday(31) = #9/4/2006#
    dteWeekDayHoliday(32) = #9/3/2007#
    dteWeekDayHoliday(33) = #9/1/2008#
    dteWeekDayHoliday(34) = #9/7/2009#
    dteWeekDayHoliday(35) = #9/6/2010#

    'Calculate delivery date
    dteDelDate = dteShipDate + intTransitDays
    'Loop thru array, if date if between shipdate and deldate set flag to add 1 day
    For i = 1 To UBound(dteWeekDayHoliday)
        If dteWeekDayHoliday(i) >= dteShipDate And dteWeekDayHoliday(i) <= dteDelDate Then
            intTransitDays = intTransitDays + 1
        End If
    Next
    
    'If greater than 6 (Friday) then add 2 days
    If Weekday(dteShipDate) + intTransitDays > 6 Then
        GroundDelDate = CStr(dteShipDate + (intTransitDays + 2))
    Else
        GroundDelDate = CStr(dteShipDate + intTransitDays)
    End If
    
    Exit Function
EH:
    m_Error = Err.Description & " in GroundDelDate"
    RaiseEvent QuoteError

End Function
'---------------------------------------------------------------------------------------
' Procedure : FHDDelDate
' DateTime  : 8/11/2004
' Purpose   : Takes a ShipDate and Transit Days and checks an array of known holidays
'             not on Sun/Mon through 2010 and adds a day to the Transit Days if any of
'             the holidays is between the ShipDate and the ShipDate + Transit Days.
'             Then adds the Transit Days to the weekday value of the ShipDate and if
'             greater than 7 adds 2 days to account for Sun and Mon.
'---------------------------------------------------------------------------------------
'
Private Function FHDDelDate(ByVal dteShipDate As Date, ByVal intTransitDays) As String

    Dim dteWeekDayHoliday(37) As Date       'Array for weekday holidays
    Dim i                                   'For loop counter
    Dim dteDelDate As Date                  'Delivery date - shipdate + transit days
    
    On Error GoTo EH
    
    'Non Sun/Mon holidays
    dteWeekDayHoliday(1) = #11/25/2004#     'Thanksgiving
    dteWeekDayHoliday(2) = #11/24/2005#
    dteWeekDayHoliday(3) = #11/23/2006#
    dteWeekDayHoliday(4) = #11/29/2007#
    dteWeekDayHoliday(5) = #11/27/2008#
    dteWeekDayHoliday(6) = #11/26/2009#
    dteWeekDayHoliday(7) = #11/25/2010#
    dteWeekDayHoliday(8) = #5/31/2004#      'Memorial day
    dteWeekDayHoliday(9) = #5/30/2005#
    dteWeekDayHoliday(10) = #5/29/2006#
    dteWeekDayHoliday(11) = #5/28/2007#
    dteWeekDayHoliday(12) = #5/26/2008#
    dteWeekDayHoliday(13) = #5/25/2009#
    dteWeekDayHoliday(14) = #5/31/2010#
    dteWeekDayHoliday(15) = #1/1/2005#      'New Year's Day
    dteWeekDayHoliday(16) = #1/1/2008#
    dteWeekDayHoliday(17) = #1/1/2009#
    dteWeekDayHoliday(18) = #1/1/2010#
    dteWeekDayHoliday(19) = #7/4/2006#      'July 4th
    dteWeekDayHoliday(20) = #7/4/2007#
    dteWeekDayHoliday(21) = #7/4/2008#
    dteWeekDayHoliday(22) = #7/4/2009#
    dteWeekDayHoliday(23) = #7/6/2005#      'Tuesday
    dteWeekDayHoliday(24) = #7/5/2006#      'Tuesday
    dteWeekDayHoliday(25) = #7/7/2010#      'Tuesday
    dteWeekDayHoliday(26) = #12/25/2004#    'Christmas Day
    dteWeekDayHoliday(27) = #12/25/2007#
    dteWeekDayHoliday(28) = #12/25/2008#
    dteWeekDayHoliday(29) = #12/25/2009#
    dteWeekDayHoliday(30) = #12/25/2010#
    dteWeekDayHoliday(31) = #9/7/2004#      'Labor Day
    dteWeekDayHoliday(32) = #9/6/2005#
    dteWeekDayHoliday(33) = #9/5/2006#
    dteWeekDayHoliday(34) = #9/4/2007#
    dteWeekDayHoliday(35) = #9/2/2008#
    dteWeekDayHoliday(36) = #9/8/2009#
    dteWeekDayHoliday(37) = #9/7/2010#

    'Calculate delivery date
    dteDelDate = dteShipDate + intTransitDays
    'Loop thru array, if date if between shipdate and deldate set flag to add 1 day
    For i = 1 To UBound(dteWeekDayHoliday)
        If dteWeekDayHoliday(i) >= dteShipDate And dteWeekDayHoliday(i) <= dteDelDate Then
            intTransitDays = intTransitDays + 1
        End If
    Next
    
    'If greater than 7 (Saturday) then add 2 days
    If Weekday(dteShipDate) + intTransitDays > 7 Then
        FHDDelDate = CStr(dteShipDate + (intTransitDays + 2))
    Else
        FHDDelDate = CStr(dteShipDate + intTransitDays)
    End If
    
    Exit Function
EH:
    m_Error = Err.Description & " in FHDDelDate"
    RaiseEvent QuoteError

End Function


